package MainPackage;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.util.ArrayList;


public class sm2 {

	//static BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
	static BufferedReader reader;		
	static boolean debug = false;
	
	public static void main(String[] args) throws Exception {
		reader = new BufferedReader(new FileReader("salesman_input.txt"));
		new sm2().run();
	}

	void runBellmanFordRun(int origin, int destination, ArrayList<int[]> al, int[] amounts){
		int towns = amounts.length;
		long[] d = new long[towns];

		for(int i=0; i< towns; i++){
			d[i] = Integer.MIN_VALUE;
		}
		d[origin] = 0;
		for(int i=1; i < towns; i++)
			for( int[] ia: al ){
				if(  d[ ia[0] ] != Integer.MIN_VALUE    &&     (d[ ia[0] ] - ia[2] + amounts[ ia[1] ]  >  d[ ia[1] ] )   ){  
					d[ ia[1] ] = d[ ia[0] ] - ia[2] + amounts[ ia[1] ] ;
				}
		
		 		if(debug){
		 			System.out.println(   d[ ia[0] ] +"  -  "+ ia[2] +"  +  "+ amounts[ ia[1] ] +"  >  "+ d[ ia[1] ]  );
					System.out.print("d: ");
					for(long value: d)
						System.out.print(value+" ");
					System.out.println(); 
				}
			}
		
		for( int[] ia: al )
			if(  d[ ia[0] ] != Integer.MIN_VALUE    &&     (d[ ia[0] ] - ia[2] + amounts[ ia[1] ]  >  d[ ia[1] ] ) ){  System.out.println("ENDLESS PROFIT"); return;  }
		
		if(d[destination] == Integer.MIN_VALUE){
			System.out.println("IMPOSSIBLE");
			return;
		}
		
		System.out.println("BEST PROFIT: "+ d[destination]);
	}
	
	void run() throws Exception{
		String line = reader.readLine();
		if(line.equals("END")) {reader.close(); return;}
		String[] split = line.split(" ");
		int towns = Integer.parseInt(split[0]);
		int roads = Integer.parseInt(split[1]);
		int origin = Integer.parseInt(split[2]);
		int destination = Integer.parseInt(split[3]);
			
		line = reader.readLine();
		String[] splitamounts = line.split(",");
		int[] amounts = new int[towns];
		for(int i=0; i< towns;i++)
			amounts[i] = Integer.parseInt(splitamounts[i]);
		
		int[][] inta = new int[roads][];
		ArrayList<int[]> al = new ArrayList<int[]>();
		for(int i = 0; i< roads; i++){
			line = reader.readLine();
			split = line.split(" ");
			int[] intsplit = new int[split.length]; 
			for(int j=0; j< split.length;j++)
				intsplit[j] = Integer.parseInt(split[j]);
			inta[i] = intsplit;
			al.add(intsplit);
		}
		new sm2().runBellmanFordRun(origin, destination, al, amounts);
		new sm2().run();
	}
	
}